<?php

namespace app\modules\v1\models;

use Yii;

/**
 * This is the model class for table "{{%_userdetail}}".
 *
 * @property integer $id        (信息ID)
 * @property string $telephone  (手机号码索引?telephone=???)
 * @property string $username   (用户名)
 * @property integer $age       (年龄)
 * @property string $sexy       (性别)
 * @property string $address    (地址)
 * @property string $email      (邮箱)
 */
class Userdetail extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%_userdetail}}';
    }

    /**
     * @inheritdoc
     * ERROR CODE
     * 401 空值
     * 402 重复
     * 403 超出范围
     * 404 不存在
     */
    public function rules()
    {
        return [
            [['telephone'], 'required','message' => 401],
            [['age'], 'integer'],
            [['telephone'],'unique','message' => 402],
            [['telephone'], 'string', 'length' => [11,11],'tooShort' => 403,'tooLong' => 403],
            [['username','email'], 'string', 'length' => [2,32],'tooShort' => 403,'tooLong' => 403],
            [['sexy'], 'string', 'max' => 8],
            [['address'], 'string', 'max' => 255, 'tooLong' => 403],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'telephone' => 'Telephone',
            'username' => 'Username',
            'age' => 'Age',
            'sexy' => 'Sexy',
            'address' => 'Address',
            'email' => 'Email',
        ];
    }
}
